use Dosvid
go

insert into Vacancy_Territories(VacancyId,TerritoryId)
select v.Id, v.TerritoryID
from Vacancies v
where v.TerritoryID is not null
go